package service;

import dao.UserDao;
import domain.User;
import util.MySpring;

//负责处理读到的数据
//负责处理业务逻辑产生的新数据
public class UserService {

	private UserDao dao = MySpring.getBean("dao.UserDao");
	
	public String login(String account,String password) {
		User user = dao.selectOne(account);
		if(user!=null) {
			if(user.getPassword().equals(password)) {
				return "登录成功";
			}
		}
		return "用户名或密码错误";
	}
	
	public String register(String account,String password) {
		User user = dao.selectOne(account);
		if(user==null) {
			dao.addOne(new User(account,password));
			return "注册成功";
		}else {
			return "用户名已存在";
		}
	}
}
